package com.delivery.controller.user;

import com.delivery.result.Result;
import com.delivery.service.DishService;
import com.delivery.vo.DishVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("user.DishController")
@RequestMapping("/user/dish")
public class DishController {

    @Autowired
    DishService dishService;

    /**
     * 根据分类id查询菜品列表 包含口味信息
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    @Cacheable(cacheNames = "dish", key = "#categoryId")
    public Result<List<DishVO>> queryByCategoryId(Integer categoryId) {

        List<DishVO> dishVOList = dishService.queryByCategoryId(categoryId);
        return Result.success(dishVOList);
    }
}
